package com.huawei.designModel.sigleton;

public class DoubleCheck {

    private DoubleCheck() {
    }

    // 使用volatile可以是的在多线程中保证生成的对象可见
    private volatile DoubleCheck instance;

    public DoubleCheck getInstance() {
        if (instance == null) {
            synchronized (DoubleCheck.class) {
                if (instance == null) {
                    instance = new DoubleCheck();
                }
            }
        }
        return instance;
    }
}
